package com.the_ring.chapter04.two;

import android.annotation.SuppressLint;
import android.app.Activity;
import android.content.Intent;
import android.os.Bundle;
import android.view.View;
import android.widget.TextView;


import androidx.appcompat.app.AppCompatActivity;


import com.the_ring.chapter04.R;

public class BActivity extends AppCompatActivity {

    TextView messageTv;

    @SuppressLint("MissingInflatedId")
    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_bactivity);

        String message = getIntent().getStringExtra("message");

        messageTv = findViewById(R.id.tv_text);
        messageTv.setText("收到 message: " + message);

        findViewById(R.id.bt_back).setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                Intent intent = new Intent();
                intent.putExtra("message", "收到消息了！！");
                setResult(Activity.RESULT_OK, intent);
                finish();
            }
        });

    }
}